<template>
  <page-meta :root-font-size="$rootFontSize"></page-meta>
  <view>
    <!--账户设置-->
    <view class="mx-4">
      <u-cell-group :border="false">
        <u-cell
          title="账户与安全"
          titleStyle="margin-left:-24rpx;"
          :isLink="true"
          rightIconStyle="fontSize:34rpx; color:#333333; margin-right:-28rpx;"
          size="large"
          @click="goTo('account-set')"
        >
        </u-cell>
        <u-cell
          title="提现账户"
          titleStyle="margin-left:-24rpx;"
          :isLink="true"
          rightIconStyle="fontSize:34rpx; color:#333333; margin-right:-28rpx;"
          size="large"
          @click="goTo('cash-account')"
        >
        </u-cell>
        <u-cell
          title="师傅名片"
          titleStyle="margin-left:-24rpx;"
          :isLink="true"
          rightIconStyle="fontSize:34rpx; color:#333333; margin-right:-28rpx;"
          size="large"
          @click="goTo('business-card')"
          v-if="user.isTrainee"
        >
        </u-cell>
      </u-cell-group>
    </view>
    <view class="fixed bottom-6 left-10 right-10" v-if="isShow">
      <!-- #ifdef H5 -->
      <view class="mb-5 text-sm text-light text-center">
        {{ user.versionInfo }}
      </view>
      <!-- #endif -->
      <!-- #ifdef APP-PLUS -->
      <view class="mb-5 text-sm text-light text-center">
        版本号：v{{ version }}
      </view>
      <!-- #endif -->
      <view
        class="w-full rounded-full leading-10 text-base h-10 text-center text-white bg-box-shadow"
        style="background: #f7412d"
        @click="onLogout"
        >退出登录</view
      >
    </view>
  </view>
</template>

<script>
import { loginOut } from '../../../package-user/services/user-details';
import { mapState } from 'vuex';

export default {
  data() {
    return {
      isShow: true,
      //版本号
      version: '',
    };
  },
  computed: {
    ...mapState({
      user: (state) => state.user,
    }),
  },
  async created() {
    // #ifdef APP-PLUS
    this.version = plus.runtime.version;
    // #endif
    this.$store.dispatch('getUser');
  },
  methods: {
    //路由跳转
    goTo(url) {
      this.$Router.push({
        name: url,
      });
    },
    //退出登录
    async onLogout() {
      const { code, data } = await loginOut();
      if (code != 200) return;
      uni.removeStorageSync('token');
      uni.removeStorageSync('expireAt');
      this.$store.commit('setUser', {});
      this.$Router.replaceAll({
        name: 'login',
      });
    },
  },
};
</script>

<style></style>
